home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16765 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ta4.cs.uiuc.edu!tandon
  2. From: tandon@cs.uiuc.edu (Ruchi Tandon)
  3. Newsgroups: comp.lang.c++
  4. Subject: Template classes - linking problem
  5. Date: 11 Apr 96 22:04:21 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <tandon.829260261@ta4.cs.uiuc.edu>
  8. NNTP-Posting-Host: ta4.cs.uiuc.edu
  9. X-Newsreader: NN version 6.5.0 (NOV)
  10.  
  11. I have a template class defined : 
  12. template <class T> List { .....  } 
  13.  
  14. The class definition & all the member functions are in the file list.h
  15.  
  16. I use this template to create lists of objects A & B. 
  17. I include list.h in the files where I use List<A> or List<B> classes.
  18.  
  19. Now when I compile my code, I get a linking error : 
  20.  
  21. ld : function <some member function of List<Vertex> class > redefined
  22.      ( found both in main.o and graph.o ) 
  23. fatal error. 
  24.  
  25.  
  26. I have included list.h in both main.c & graph.c 
  27. Why does this happen & how can I get over this problem 
  28.  
  29. Thanks 
  30.  
  31. ruchi
  32. -- 
  33. ___________________________________________________________________________
  34.    Name            : Ruchi Tandon
  35.    Office          : 1105 DCL, 1304 W Springfield Ave, Urbana, IL 61801
  36.    Postal Address  : 2413 DCL, 1304 W Springfield Ave, Urbana, IL 61801 
  37.